<?php session_start(); ?>

<?php
    $_SESSION['LOGGED_IN'] = false;
    include "Employee.php";
    include "EmployeeDao.php";
    include "Datasource.php";
    if(isset($_POST['user']) && isset($_POST['pass']))
    {
        //theanykey.db.4987544.hostedresource.com
        //$conn = new Datasource("localhost","theanykey","root","");
        $conn = new Datasource("theanykey.db.4987544.hostedresource.com","theanykey","theanykey","Triumph123");
        $employee = new Employee();
        $employeeDao = new EmployeeDao();
        $employee->setLoginID($_POST['user']);
        $_SESSION['user'] = $_POST['user'];
        $employee->setPassword(md5($_POST['pass']));
        $_SESSION['pass'] = md5($_POST['pass']);
        $results = $employeeDao->searchMatching($conn, $employee);
        if(empty($results) == false)
        {
           $_SESSION['LOGGED_IN'] = true;
        }
    }
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Header</title>
    </head>
    <body bgcolor="#666666">
	<body text="#FFFFFF">
	<body link="white" alink="white" vlink="white"> 
        <center>
            <img src="images/Triumph_01.gif" width="1000" height="176" alt="">
            <table width="1000"  bgcolor='#454343'>
                <tr>
	
                        <?php
                        // put your code here
                            if ($_SESSION['LOGGED_IN'] == true)
                            {
                                print("<td align='left'><input type='button' value='Ticket Menu' onClick=\"parent.main.location='TicketMenu.php'\">&nbsp;
                                       <input type='button' value='Maintenance Menu' onClick=\"parent.main.location='MaintenanceMenu.html'\"></td>
                                       <td align='right'><a href='header.php' onClick=\"parent.main.location='ttshome.php'\">Log Out ".$_SESSION['user']."</a></td>");
                            }
                            else
                            {
                                print("<td align='right'><form method='post' action='header.php'>
                                        Username: <input type='text' length='25' label='Username:' id='user' name='user'>
                                        Password: <input type='password' length='25' label='Password:' id='pass' name='pass'>
                                        <input type='submit' label='Login' value='Login'>
                                        </form></td>");

                            }
                        ?>
						
                </tr>

            </table>

        </center>


    </body>
</html>

